import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

///
///Flutter中提供了一些剪裁函数，用于对组件进行剪裁。
///  剪裁Widget	作用
/// ClipOval	子组件为正方形时剪裁为内贴圆形，为矩形时，剪裁为内贴椭圆
///  ClipRRect	将子组件剪裁为圆角矩形
/// ClipRect	剪裁子组件到实际占用的矩形大小（溢出部分剪裁）
///
class ClipWidget extends StatelessWidget {
  ClipWidget({Key ? key, @required this.text}) : super(key: key);
  final String ?text;

  @override
  Widget build(BuildContext context) {
    Widget avater = Image.asset(
      "images/iron_man.jpg",
      width:90,
    );
    return Scaffold(
      appBar: AppBar(
        title: Text(text??""),
      ),
      body: Center(
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.all(10),
              alignment: Alignment.center,
              child: Wrap(
                children: [
                  avater,
                  SizedBox(
                    width: 30,
                  ),
                  ClipOval(
                    child: avater,
                  ), //剪裁为圆形
                  SizedBox(
                    width: 30,
                  ),
                  ClipRRect(
                    //剪裁为圆角矩形
                    borderRadius: BorderRadius.circular(5.0),
                    child: avater,
                  )
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.all(10),
              alignment: Alignment.center,
              child: Row(
                children: [
                  ClipRRect(
                    //剪裁为圆角矩形
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(10.0),
                        topRight: Radius.circular(10.0),
                        bottomLeft: Radius.circular(0),
                        bottomRight: Radius.circular(0)),
                    child: avater,
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
